/**  

* @Title: AdministratorDaoHibernate.java 

* @Package com.gxbadge.dao.impl 

* @Description: TODO(用一句话描述该文件做什么) 

* @author CST

* @version V1.0  

*/ 

package com.gxbadge.dao.impl;

import java.util.List;

import com.gxbadge.dao.CategoryDao;
import com.gxbadge.dao.base.BaseHibernateDaoSupport;
import com.gxbadge.model.Category;

public class CategoryDaoHibernate extends BaseHibernateDaoSupport implements CategoryDao {

	/* 
	 * {见接口方法说明}
	 */
	public void delete(Category cate) {
		
		this.getHibernateTemplate().delete(cate);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public List<Category> findCateAll() {
		
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public Category findCategoryByCateId(Integer cateId) {
		
		Category cate = this.getHibernateTemplate().get(Category.class, cateId);
		if(cate!=null){
			return cate;
		}
		return null;
	}
	
	public List<Category> findCategoryByCatePid(Integer catePid){
		
		List<Category> cateList = this.getHibernateTemplate().find("from Category as c where c.catePid=?", catePid);
		if(cateList!=null&&cateList.size()>=1){
			
			return cateList;
		}else{
			return null;
		}
		
	}
	/* 
	 * {见接口方法说明}
	 */
	public void save(Category cate) {
		
		this.getHibernateTemplate().save(cate);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public void update(Category cate) {
		
		this.getHibernateTemplate().update(cate);
		
	}
	
	public Category findCateByNote(String note){
		
		List<Category> cateList = this.getHibernateTemplate().find("from Category as c where c.note=?", note);
		if(cateList!=null&&cateList.size()>=1){
			return cateList.get(0);
		}
		return null;
		
		
	}
	
}
